home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 8 / Eagles_Nest_Mac_Collection_Disc_8.TOAST / Developer Tools⁄Additions / IntermediatC / Ships #6 / teacher's control.c < prev    next >
C/C++ Source or Header  |  1990-10-25  |  1KB  |  51 lines

  1. /*
  2.  
  3. CONTROL.C
  4.  
  5. Ships at Sea:
  6.  
  7. Create 25 ship locations (x,y) between -100 and 100 for each x and y.  Determine
  8. which 2 of the 25 ships are closest together.  Print the locations of all ships
  9. and the numbers of the 2 closest ships.  Three modules must be used:
  10.  
  11. control.c        contains main()
  12. compute.c        creates the ship locations and locates the 2 closest ships
  13. output.c        prints data to disk
  14.  
  15. */
  16.  
  17. /*
  18.  
  19. This is control.c.  This module will call upon other modules
  20. to create a list of 25 ships, to locate the nearest pair, and
  21. to output their locations and the nearest hull numbers.
  22. */
  23.  
  24.  
  25. /* No includes needed in this module */
  26.  
  27. #define SHIPS_AT_SEA    25
  28.  
  29.  
  30. /* Declarations of functions defined in other modules. */
  31.  
  32. extern void create_locations
  33.        (double latitudes[], double longitudes[], int no_of_ships);
  34. extern void locate_nearest_pair
  35.        (int nearest_subscripts[], double latitudes[], double longitudes[],
  36.         int no_of_ships);
  37. extern void produce_output
  38.        (int nearest_subscripts[], double latitudes[], double longitudes[],
  39.         int no_of_ships);
  40.  
  41.  
  42. main()
  43.    {
  44.    double latitudes[SHIPS_AT_SEA], longitudes[SHIPS_AT_SEA];
  45.    int nearest_subscripts[2];
  46.    
  47.    create_locations(latitudes, longitudes, SHIPS_AT_SEA);
  48.    locate_nearest_pair(nearest_subscripts, latitudes, longitudes, SHIPS_AT_SEA);
  49.    produce_output(nearest_subscripts, latitudes, longitudes, SHIPS_AT_SEA);
  50.    }
  51.